<template>
	<view class="dian">
		<view v-for="i in station">
			<view class="cu-card case no-card" v-if="i.siteId==id">
				<view class="cu-item shadow">
					<view class="image">
						<image :src="i.img" mode="widthFix">
						</image>
						<view class="cu-tag bg-blue">{{i.businessHours}}</view>
						<view class="cu-bar bg-shadeBottom"> <text class="text-cut">{{i.introduce}}</text></view>
					</view>
					<view class="cu-list menu-avatar">
						<view class="cu-item">
							<view class="cu-avatar round lg"
								style="background-image:url(https://ossweb-img.qq.com/images/lol/web201310/skin/big10006.jpg);">
							</view>
							<view class="content flex-sub">
								<view class="text-grey">{{i.siteName}}</view>
								<view class="text-gray text-sm flex justify-between" v-if="i.cleaningType != ''">
									洗车类型:{{i.cleaningType}}
								</view>
								<view class="text-gray text-sm flex justify-between" v-if="i.cleaningType == ''">
									洗车类型:未知
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view style="padding: 40rpx;">
			<button class="cu-btn block bg-blue margin-tb-sm lg" @click="openMap">
				<text class="cuIcon-locationfill"></text>
				导航
			</button>
			<button class="cu-btn block bg-green margin-tb-sm lg" @click="subscribe">
				<text class="cuIcon-form"></text>
				预约
			</button>
			<button class="cu-btn block bg-red margin-tb-sm lg" @click="fankui">
				<text class="cuIcon-message"></text>
				反馈
			</button>
		</view>


	</view>

</template>

<script>
	export default {
		data() {
			return {

				info: {},
				title: '',
				id: '',
				station: [],
				token:''



			}
		},
		onLoad(e) {
			this.token = uni.getStorageSync("token")
			if(this.token == ''){
				uni.showToast({
					title: '请先登录',
					icon:"error"
				});
				uni.navigateTo({
					url:'/pages/login/login'
				})
			}
			uni.setNavigationBarTitle({
				title: e.title
			})
			this.id = e.id
			this.title = e.title
			uni.request({
				url: 'http://127.0.0.1:9000/site/findAllSite',
				method: 'GET',
				data: {},
				success: res => {
					var rs = res.data.data.sitelist
					console.log(rs);
					rs[0].img =
						"https://img.zcool.cn/community/01db2060630dee11013e87f41019d5.jpg@1280w_1l_2o_100sh.jpg"
					rs[1].img =
						"https://ts1.cn.mm.bing.net/th/id/R-C.adc24789fe5acc8336551e112b2e3a78?rik=dn0YhUzfCRam9A&riu=http%3a%2f%2fs3.xchuxing.com%2fxchuxing%2farticle%2f2021%2f06%2f21%2f5667a202106212209274611.jpeg&ehk=oSlx9KZjH52a6cYjw%2flPYQSHE9LuFQEjtVuJsQYkdrs%3d&risl=&pid=ImgRaw&r=0"
					rs[2].img = "https://www.szxilepai.com/uploads/allimg/xlp/wenzhang/20190425/wangdian3.jpg"
					for (var i = 3; i < rs.length; i++) {
						rs[i].img =
							"https://img.zcool.cn/community/01db2060630dee11013e87f41019d5.jpg@1280w_1l_2o_100sh.jpg"
					}
					this.station = rs
				},
				fail: () => {},
				complete: () => {}
			});

		},
		methods: {
			navigate: function(uri) {
				uni.navigateTo({
					url: `/pages/${uri}`
				})
			},
			change(e) {
				this.current = e.detail.current;
			},
			fankui() {
				uni.navigateTo({
					url: 'fankui',
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			openMap() {
				uni.openLocation({
					latitude: 29.05528,
					longitude: 111.672436,
					name: this.title
				});
			},
			subscribe() {
				var that =this
				uni.request({
					url: "http://127.0.0.1:9000/order/addOrder",
					method: "post",
					header: {
						Authorization: that.token
					},
					data: {
						"carId": 1,
						"orderState": 0,
						"paySum": 0,
						"userId": 1
					}
				}).then((res) => {
					uni.showToast({
						title: '已预约，洗车完毕后可去订单确认完成',
						icon:'success'
					});
					
				})
			}

		}


	}
</script>

<style lang="less">
	page {
		background-color: white;
	}
</style>
